package com.sx.web;

import com.sx.service.Impl.StudentServiceImpl;
import com.sx.service.StudentService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(urlPatterns = "/teststuno")
public class TestStuNoServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String studentnumber = req.getParameter("studentnumber");

        resp.setContentType("text/html;charset=utf-8");
        PrintWriter writer = resp.getWriter();
        StudentService service = new StudentServiceImpl();
        int i = service.findByStuNo(studentnumber);
        if(i>0){
            writer.println("账户已被注册");
        }else{
            writer.println("账户可用");
        }
    }
}
